<?php
    App::import('Model', 'Person');


    class PersonTestCase extends CakeTestCase {
        var $fixtures = array('app.person', 'app.families_person',
                              'app.family', 'app.event', 'app.events_family');
    
    	function testGetPeoplefromIDs() {
    		$this->Person =& ClassRegistry::init('Person');
    		
    		$result = $this->Person->getPeopleFromIDs(array(2));
    		$expected = array(2 => array(
			'id' => 2,
			'first_name' => 'first2',
			'last_name' => 'last2',
			'username' => 'test2@test.com',
			'created' => '0000-00-00 00:00:00'));
			$this->assertEqual($result, $expected);
    	}
    
    	function testGetPersonFromID() {
    		$this->Person =& ClassRegistry::init('Person');
    		
    		$result = $this->Person->getPersonFromID(2);
    		$expected = array(
			'id' => 2,
			'first_name' => 'first2',
			'last_name' => 'last2',
			'username' => 'test2@test.com',
			'created' => '0000-00-00 00:00:00');
			$this->assertEqual($result, $expected);
    	}
    
        function testGetFamiliesFromPerson() {
            $this->Person =& ClassRegistry::init('Person');
            
            // Test multiple return result
            $result = $this->Person->getFamiliesFromPerson(1);
            $expected = array(
                                array('id' => 1, 'name' => 'testFamily1'),
                                array('id' => 2, 'name' => 'testFamily2'));
                                
            $this->assertEqual($result, $expected);
            
            // Test empty result
            $result = $this->Person->getFamiliesFromPerson(2);
            $expected = array();
            $this->assertEqual($result, $expected);              
        }
        
        function testCanViewEvent() {
            $this->Person =& ClassRegistry::init('Person');
            
            // Test CAN view event
            $result = $this->Person->canViewEvent(1, 1);
            $this->assertTrue($result);
            
            // Test CANT view event
            $result = $this->Person->canViewEvent(2, 1);
            $this->assertFalse($result);
        }
        
        function testIsEventAdmin() {
            $this->Person =& ClassRegistry::init('Person');
            
            // Test IS event admin
            $result = $this->Person->isEventAdmin(1, 1);
            $this->assertTrue($result);
            
            // Test ISNT event admin
            $result = $this->Person->isEventAdmin(2, 1);
            $this->assertFalse($result);
        }
    }
 

?>
